home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 19
/
CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso
/
CUCD
/
Utilities
/
Scion
/
ARexx
/
Scion2GEDCOM.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1997-11-04
|
28KB
|
924 lines
/****************************************************************************
* *
* $VER: Scion2GEDCOM 2.45 (24 Oct 1997)
* *
* Written by Freddy Ariës *
* Address: Lindeboomweg 7, NL-7135 KE Harreveld, The Netherlands. *
* *
* This program was created to export the Scion data into the GEDCOM file *
* format. It should work pretty good by now, although no guarantees *
* whatsoever can be given. If you have any problems using this script, *
* please describe them to me, as detailed as possible (and please also *
* tell me what program you are using to read the GEDCOM file), then I will *
* try to work out a solution. *
* *
* GEDCOM was developed by the Family History Department of the Church of *
* Jesus Christ of Latter-day Saints to provide a flexible uniform format *
* for exchanging computerized genealogical data. GEDCOM is an acronym for *
* GEnealogical Data COMmunication. GEDCOM is provided to foster the *
* sharing of genealogical information and the development of a wide range *
* of inter-operable software products to assist genealogists, historians, *
* and other researchers. *
* *
* + SCION must be running for this AREXX script to work. *
* + This script uses (by default) the rexxreqtools.library (which requires *
* a version of reqtools larger than 2.0 and rexxsyslib.library) *
* If you do not have these, run SetDefaults.rexx to change the settings. *
* + Dates should be in English, and in the format "DD MMM YYYY" or *
* "DD-MMM-YYYY", if you don't want any problems with programs importing *
* the GEDCOM data. *
* If the dates in your database are not in English, please run the *
* Translate.rexx script first! *
* *
* DONE: - Progress indicator, using rexxarplib.library (requested by *
* Robbie J. Akins himself). *
* - Creation of QUAY value for date and place fields ending with '?' *
* - Output of Scion's external note files to GEDCOM comment lines *
* (option) *
* - Reference field is now output to GEDCOM's SOUR structure. *
* - Export of Celebrant and Witness fields, as well as Endreasons *
* 'None' and 'Death' (temporary solution; experimental, until I *
* find a better way to do it). If any of these fields is *
* misinterpreted by your system, then please report this. *
* - Now uses preference file for default settings *
* - Inclusion of self-defined name/address data in GEDCOM file *
* (optional) *
* - CHARset set to ISO8859-1 (was: AMIGA); suggested by Robbie. *
* - Support for V5 date formats/preparer fields/notes attachments/ *
* personal addresses (GEDCOM 5.3 doesn't support family addresses) *
* *
* TO DO (but low priority, unless someone really wants this[?]): *
* - Add Shell options for processing of Note files *
* - Add support for other character sets (now Amiga extended ASCII codes *
* are assumed, even though the GEDCOM format specifies the ANSEL codes *
* as the default) *
* - Maybe some kind of limited export facility *
* - Suggestions, comments, bugreports, donations, etc. are appreciated. *
* *
****************************************************************************/
options failat 20; options results
arg outname outval
versionstr = "2.45"
/* Don't change the settings here! Run SetDefaults.rexx instead! */
usereq = 1; prgrs = 1; pgopen = 0
outp = 1; output = stdout; scrdev = stdout
notesdir = ""; pscr = ""
subf = 0; subm. = ""
PSCR = "SCIONGEN"
scrname = "CON:0//639//Scion_Output/AUTO/WAIT/CLOSE/SCREEN"
incnote = 0; /* include external note files */
NL = '0A'x
signal on IOERR
do while outname = '?'
writeln(stdout, "OUTFILE/A,QUIET/S,NOREQ/S")
pull outname outval
end
/* read preferences file */
if open(pfile, 'ENV:Scion/ScionRexx.prefs', 'r') then do
do while ~eof(pfile)
inln = readln(pfile)
if inln ~= "" then do
wstr = upper(word(inln, 1))
select
when wstr = "NOTES" then
notesdir = strip(delstr(inln, 1, length(wstr)), 'b', ' "')
when wstr = "USEREQ" then
usereq = 1
when wstr = "NOUSEREQ" then
usereq = 0
when wstr = "PROGRESS" then
prgrs = 1
when wstr = "NOPROGRESS" then
prgrs = 0
when wstr = "PUBSCREEN" then
pscr = strip(delstr(inln, 1, length(wstr)), 'b', ' "')
when wstr = "SUB_N0" then
subm.0 = delstr(inln, 1, length(wstr)+1)
when wstr = "SUB_A1" then
subm.1 = delstr(inln, 1, length(wstr)+1)
when wstr = "SUB_A2" then
subm.2 = delstr(inln, 1, length(wstr)+1)
when wstr = "SUB_A3" then
subm.3 = delstr(inln, 1, length(wstr)+1)
when wstr = "SUB_T0" then
subm.4 = delstr(inln, 1, length(wstr)+1)
when wstr = "SUB_N1" then
subm.5 = delstr(inln, 1, length(wstr)+1)
when wstr = "SUB_N2" then
subm.6 = delstr(inln, 1, length(wstr)+1)
when wstr = "SUB_N3" then
subm.7 = delstr(inln, 1, length(wstr)+1)
when wstr = "SUB_F0" then
subf = bittst(b2c(strip(delstr(inln, 1, length(wstr)), 'b')), 0)
otherwise
/* unrecognized? skip */
end
end
end
close(pfile)
end
if pscr = "" | (pscr ~= "WORKBENCH" & ~show('p', pscr)) then
pscr = "SCIONGEN"
wstr = right(notesdir, 1)
if wstr ~= '/' & wstr ~= ':' then notesdir = ""
scrname = scrname||pscr
/* parse command line options, to enable calling the script automatically,
* eg. from a function key. This gets priority over global settings!
*/
if outname ~= "" then do
if outname = "QUIET" | outname = "NOREQ" then do
outval = outname; outname = ""
end
end
if outval = "QUIET" then do
outp = 0; usereq = 0; prgrs = 0
end
else if outval = "NOREQ" then do
usereq = 0; prgrs = 0
end
if usereq & ~show('l','rexxreqtools.library') then do
if exists('libs:rexxreqtools.library') then
call addlib('rexxreqtools.library',0,-30,0)
else do
usereq = 0; outp = 1
Tell("Unable to open rexxreqtools.library - using text output")
end
end
if ~usereq then prgrs = 0
if ~show('l','rexxarplib.library') then do
if exists('libs:rexxarplib.library') then do
/* rexxarplib is present - start it */
call addlib('rexxarplib.library',0,-30,0)
screentofront(pscr)
end
else
prgrs = 0
end
else do
/* rexxarplib is already in memory */
screentofront(pscr)
end
/* Originally stolen from Peter Billing - thanks Peter ;-) */
if ~show('P','SCIONGEN') then do
EndString('I am sorry to say that the SCION Genealogist' || NL ||,
'database is not available. Please start the' || NL ||,
'SCION program BEFORE using this script!')
end
MyPort = "SCIONGEN"
Address value MyPort
GETDBNAME
dbname = upper(RESULT)
GETPROGVERSION
prgvers = RESULT
if outp & ~usereq then do
if pscr ~= "WORKBENCH" then do
scrdev = 'SCNS2GSCR'
if ~open(scrdev, scrname, 'w') then scrdev = stdout
end
Tell("Scion to GEDCOM conversion script v"||versionstr||" by Freddy Ariës")
Tell("Database: "||dbname)
if prgvers < 5 then do
Tell("(Make sure the date fields are in English!)"|| NL)
end
end
/* It may be a good habit to add the ".scion" extension */
/* to Scion database files */
dblen = length(dbname)
if dblen>6 & right(dbname, 6)=".SCION" then dbname=left(dbname, dblen - 6)
if outname = "" then do
if outp then do
if usereq then do
odev = rtezrequest('Current Scion database: '||dbname||NL||NL||,
'Where should the GEDCOM output be sent to?'||,
'',' _File |_Printer|_Screen|_Nowhere','Scion to GEDCOM v'||versionstr||' by Freddy Ariës','rt_pubscrname = '||PSCR)
select
when odev = 1 then do
/* We need a file requester for further data */
outname = rtfilerequest(,dbname||'.GED','Output filename',,'rt_pubscrname = '||PSCR||' rtfi_initialpath = RAM:',)
if outname = '' then
outname = dbname||'.GED'
end
when odev = 2 then
outname = 'PRT:'
when odev = 3 then
outname = 'STDOUT'
otherwise
EndString("Aborted.")
/* You selected 'Nowhere' */
end
end
else do
Tell("Enter output file (filename with complete path, or PRT: for printer,")
TellNN("or STDOUT for screen): ")
outname = readln(scrdev)
outname = strip(outname, 'b', ' "')
Tell("Destination: "||outname)
TellNN("Continue (y/n)? ")
conf = readln(scrdev)
conf = upper(left(conf, 1))
/* Note that left works on empty strings ("") too! */
if conf ~= "Y" then EndString("Aborted.")
Tell("")
end
end
else
outname = "RAM:"dbname".GED"
/* If we're not allowed to use stdout, default to this filename */
end
if outp then do
if usereq then do
incnote = rtezrequest("Include Scion's external Note files "||,
NL||"in GEDCOM comment lines?"||,
'',' _Yes| _No ','Input Request:','rt_pubscrname = '||PSCR)
if incnote & notesdir = "" then do
GETDBPATH
dbpath = RESULT
notesdir = rtfilerequest(,,'Select Scion Notes Directory:','_Ok','rt_pubscrname = '||PSCR||' rtfi_flags = freqf_nofiles rtfi_initialpath = '||dbpath,fres)
if fres = 0 then incnote = 0
/* User cancelled requester: external note files are not used */
end
end
else do
Tell("Include Scion's external Note files in GEDCOM comment lines?")
TellNN("(y/n) : ")
ptmp = readln(scrdev)
ptmp = upper(left(ptmp, 1))
if ptmp = "Y" then incnote = 1
else incnote = 0
if incnote & notesdir = "" then do
ptmp = ""
do until ptmp = ":" | ptmp = "/"
Tell("Enter full directory name where Scion's note files are located.")
TellNN("(MUST end with ':' or '/'): ")
pname = readln(scrdev)
pname = strip(pname, 'b', ' "')
ptmp = right(pname, 1)
end
notesdir = pname
end
end
end
if outname ~= "STDOUT" then do
output = 'OUTPUT'
if ~open(output, outname, "w") then
EndString("ERROR: Unable to open output file.")
end
else do
if ~outp | usereq then do /* output screen wasn't opened yet! */
scrdev = 'SCNS2GSCR'
if ~open(scrdev, scrname, 'w') then scrdev = stdout
end
output = scrdev
end
if ~usereq then
Tell("Be patient - this may take a while...")
writeln(output, "0 HEAD")
writeln(output, "1 SOUR SCION_AMIGA")
writeln(output, "2 NAME Scion Genealogist")
writeln(output, "2 VERS "||prgvers)
writeln(output, "2 CORP Robbie J. Akins")
writeln(output, "3 ADDR 5 Austin Street, Wellington 6001, New Zealand")
str = "1 DATE" upper(date())
writeln(output, str)
str = "1 FILE" dbname
writeln(output, str)
writeln(output, "1 GEDC")
writeln(output, "2 VERS 5.3")
writeln(output, "1 CHAR ISO8859-1"); /* 8-bit extended ASCII, Amiga format */
if (prgvers >= 5) then do
GETBRKCHAR
brkchar = RESULT
GETPREPARER
prep_addr = RESULT
if prep_addr ~= '' then
do
writeln(output, "1 SUBM @S1@")
writeln(output, "0 @S1@ SUBM")
PARSE VAR prep_addr p_name (brkchar) addr1 (brkchar) addr2 (brkchar) addr3 (brkchar)
if p_name ~= '' then
do
writeln(output, "1 NAME "||p_name)
end
if addr1 ~= '' then
do
writeln(output, "1 ADDR "||addr1)
end
if addr2 ~= '' then
do
writeln(output, "2 CONT "||addr2)
end
if addr3 ~= '' then
do
writeln(output, "2 CONT "||addr3)
end
GETPREPPHONE
prep_phone = RESULT
if prep_phone ~= '' then
do
writeln(output, "2 PHON "||prep_phone)
end
end
end
else if subf & (subm.0 ~= "") then do
writeln(output, "1 SUBM @S1@")
writeln(output, "0 @S1@ SUBM")
writeln(output, "1 NAME "||subm.0)
if subm.5 ~= "" then do
writeln(output, "2 NOTE "||subm.5)
if subm.6 ~= "" then writeln(output, "3 CONT "||subm.6)
if subm.7 ~= "" then writeln(output, "3 CONT "||subm.7)
end
if subm.1 ~= "" then do
writeln(output, "1 ADDR "||subm.1)
if subm.2 ~= "" then writeln(output, "2 CONT "||subm.2)
if subm.3 ~= "" then writeln(output, "2 CONT "||subm.3)
if subm.4 ~= "" then writeln(output, "2 PHON "||subm.4)
end
end
if prgrs then do
Postmsg(10, 10, "Scion to GEDCOM (by Freddy Ariës)\Database: "||dbname||"\Processing person:\ ", ""||PSCR"")
pgopen = 1
end
if (prgvers >= 5) then
do
GETFIRSTIRN
i = RESULT
GETLASTIRN
TotalIRN = RESULT
GETBRKCHAR
brkchar = RESULT
end
else do
GETTOTALIRN
TotalIRN = RESULT
i = 1
end
do while (i > 0) & (i <= TotalIRN)
if pgopen then Postmsg(,,"\\\"||i||" (of "||TotalIRN||")", PSCR)
EXISTPERSON i
if RESULT = 'YES' then
do
str = "0 @I"i"@ INDI"
writeln(output, str)
GETFIRSTNAME i
fnames = RESULT
fnames = translate(fnames, ';', '/')
/* Fixed since v2.13: no '/' characters allowed in GEDCOM namestring! */
GETLASTNAME i
lname = RESULT
lname = translate(lname, ';', '/')
str = "1 NAME "fnames"/"lname"/"
writeln(output, str)
GETSEX i
sx = RESULT
if sx = "M" | sx = "F" then do
/* If sex is undefined ('?'), don't output anything */
str = "1 SEX" sx
writeln(output, str)
end
GETBIRTHDATE i 1
datestr = ParseDate(upper(RESULT))
GETBIRTHPLACE i
placestr = RESULT
if datestr ~= "" | placestr ~= "" then do
writeln(output, "1 BIRT")
DoOutputDate(datestr, output)
DoOutputPlace(placestr, output)
end
GETBAPTISMDATE i 1
datestr = ParseDate(upper(RESULT))
GETBAPTISMPLACE i
placestr = RESULT
if datestr ~= "" | placestr ~= "" then do
writeln(output, "1 BAPM")
DoOutputDate(datestr, output)
DoOutputPlace(placestr, output)
end
GETDEATHDATE i 1
datestr = ParseDate(RESULT)
GETDEATHPLACE i
placestr = RESULT
GETDIEDOF i
diedofstr = RESULT
if datestr ~= "" | placestr ~= "" | diedofstr ~= "" then do
writeln(output, "1 DEAT")
DoOutputDate(datestr, output)
DoOutputPlace(placestr, output)
if diedofstr ~= "" then do
str = "2 CAUS" diedofstr
writeln(output, str)
end
end
GETBURIALDATE i 1
datestr = ParseDate(RESULT)
GETBURIALPLACE i
placestr = RESULT
if datestr ~= "" | placestr ~= "" then do
writeln(output, "1 BURI")
DoOutputDate(datestr, output)
DoOutputPlace(placestr, output)
end
if prgvers >= 5 then do
GETPERSADDR i
pers_addr = RESULT
PARSE VAR pers_addr line_1 (brkchar) line_2 (brkchar) line_3 (brkchar) line_4 (brkchar)
GETPERSPHONE i
pers_phone = RESULT
if line_1 ~= '' then do
writeln(output, "1 ADDR "||line_1)
if line_2 ~= '' then do
writeln(output, "2 CONT "||line_2)
end
if line_3 ~= '' then do
writeln(output, "2 CONT "||line_3)
end
if line_4 ~= '' then do
writeln(output, "2 CONT "||line_4)
end
if pers_phone ~= '' then do
writeln(output, "2 PHON "||pers_phone)
end
end
end
GETRELIGION i
rs1 = RESULT
if rs1 ~= "" then do
str = "1 RELI" rs1
writeln(output, str)
end
GETEDUCATION i
rs1 = RESULT
if rs1 ~= "" then do
str = "1 EDUC" rs1
writeln(output, str)
end
GETOCCUPATION i
rs1 = RESULT
if rs1 ~= "" then do
str = "1 OCCU" rs1
writeln(output, str)
end
comset = 0
GETPERSCOMMENT i
rs1 = RESULT
if rs1 ~= "" & rs1 ~= "[see notes]" then do
str = "1 NOTE" rs1
writeln(output, str)
comset = 1
end
if incnote then do
iname = notesdir||"PN"||i||"."||dbname
if prgvers >= 5 then do
GETPERSNOTE i
notespath = RESULT
if notespath ~= '' then
iname = notespath
end
ParseCommentFile(iname, comset)
end
GETPERSREFS i
rs2 = RESULT
if rs2 ~= "" then do
str = "1 SOUR" rs2
writeln(output, str)
end
GETPARENTS i
ParFGRN = RESULT
EXISTFAMILY ParFGRN
if RESULT = 'YES' then do
str = "1 FAMC @F"ParFGRN"@"
writeln(output, str)
end
HuwNum = 0
GETMARRIAGE i HuwNum
MarrFGRN = RESULT
do while MarrFGRN ~= ""
EXISTFAMILY MarrFGRN
if RESULT = 'YES' then do
str = "1 FAMS @F"MarrFGRN"@"
writeln(output, str)
end
HuwNum = HuwNum + 1
GETMARRIAGE i HuwNum
MarrFGRN = RESULT
end
end
if (prgvers >= 5) then
do
GETNEXTIRN i
i = RESULT
end
else do
i = i + 1
end
end
if ~usereq & output ~= scrdev then
do
Tell("Number of persons output: "||TotalIRN)
/* output to screen only if it doesn't end up
* in the middle of the GEDCOM file!
*/
end
/* Now the list of families... */
if pgopen then Postmsg(,, "\\Processing family:\ ", PSCR)
if (prgvers >= 5) then
do
GETFIRSTFGRN
i = RESULT
GETLASTFGRN
TotalFGRN = RESULT
end
else do
GETTOTALFGRN
TotalFGRN = RESULT
i = 1
end
do while (i > 0) & (i <= TotalFGRN)
if pgopen then Postmsg(,, "\\\"||i||" (of "||TotalFGRN||")", PSCR)
EXISTFAMILY i
if RESULT = 'YES' then do
str = "0 @F"i"@ FAM"
writeln(output, str)
GETPRINCIPAL i
husb = RESULT
if husb ~= "" then do
EXISTPERSON husb
if RESULT = 'YES' then do
GETSEX husb
hsx = RESULT
/* Note: GEDCOM requires 1 husband (male) and 1 wife (female).
* Scion allows more unconventional partnerships as well, so we have
* to improvise a bit here...
*/
GETSPOUSE i
wife = RESULT
if wife ~= "" then do
EXISTPERSON wife
if RESULT = 'YES' then do
if hsx = "M" then wsx = "F"
else if hsx = "F" then wsx = "M"
else do
/* principal's sex is undefined. Try to determine it
* using the sex of the spouse. If both are undefined,
* assume principal is male and spouse is female.
*/
GETSEX wife
wsx = RESULT
if wsx = "M" then hsx = "F"
else hsx = "M"
end
if wsx = "M" then do
str = "1 HUSB @I"wife"@"
writeln(output, str)
end
else do
str = "1 WIFE @I"wife"@"
writeln(output, str)
end
end
end
if hsx ~= "F" then do
str = "1 HUSB @I"husb"@"
writeln(output, str)
end
else do
str = "1 WIFE @I"husb"@"
writeln(output, str)
end
end
end
GETENGAGEDATE i 1
datestr = ParseDate(RESULT)
GETENGAGEPLACE i
placestr = RESULT
if datestr ~= "" | placestr ~= "" then do
writeln(output, "1 ENGA")
DoOutputDate(datestr, output)
DoOutputPlace(placestr, output)
end
datestr = ""; placestr = ""
GETMARRYDATE i 1
datestr = ParseDate(RESULT)
GETMARRYPLACE i
placestr = RESULT
GETCELEBRANT i
clbrnt = RESULT
GETWITNESS i
wtness = RESULT
if datestr ~= "" | placestr ~= "" | clbrnt ~= "" | wtness ~= "" then do
writeln(output, "1 MARR")
DoOutputDate(datestr, output)
DoOutputPlace(placestr, output)
if clbrnt ~= "" then do
str = "2 OFFI" clbrnt
writeln(output, str)
end
if wtness ~= "" then do
str = "2 WITN" wtness
writeln(output, str)
end
/* Note that OFFI and WITN in this context are not official GEDCOM 5.3,
* but at least this way, they won't get lost when we export Scion data
* and then import the exported file again.
*/
end
GETENDING i
endstr = RESULT
if endstr >= 1 & endstr <= 5 then do
/* DIV N is used eg. by PAF 2.2. It's not official GEDCOM 5.3, but I
* hope other programs can recognize it and are not confused by it.
*/
if endstr = 1 then
writeln(output, "1 DIV N")
else if endstr = 2 then do
writeln(output, "1 DIV")
writeln(output, "2 TYPE DIVORCE")
end
else if endstr = 3 then do
writeln(output, "1 DIV")
writeln(output, "2 TYPE SEPARATED")
end
else if endstr = 4 then
writeln(output, "1 ANUL")
else if endstr = 5 then do
writeln(output, "1 DIV N")
writeln(output, "2 TYPE DEATH")
/* I hope this doesn't confuse other programs too much !?! */
/* This is just a temporary solution, until I find a better way */
end
datestr = ""; placestr = ""
GETENDDATE i 1
datestr = ParseDate(RESULT)
DoOutputDate(datestr, output)
GETENDPLACE i
placestr = RESULT
DoOutputPlace(placestr, output)
end
comset = 0
GETFAMCOMMENT i
rs1 = RESULT
if rs1 ~= "" & rs1 ~= "[see notes]" then do
str = "1 NOTE" rs1
writeln(output, str)
comset = 1
end
if incnote then do
fname = notesdir||"FN"||i||"."||dbname
if prgvers >= 5 then do
GETFAMNOTE i
notespath = RESULT
if notespath ~= '' then
fname = notespath
end
ParseCommentFile(fname, comset)
end
GETFAMREFS i
rs2 = RESULT
if rs2 ~= "" then do
str = "1 SOUR" rs2
writeln(output, str)
end
ChNum = 0
GETCHILD i ChNum
ChIRN = RESULT
do while ChIRN ~= ""
EXISTPERSON ChIRN
if RESULT = 'YES' then do
str = "1 CHIL @I"ChIRN"@"
writeln(output, str)
end
ChNum = ChNum + 1
GETCHILD i ChNum
ChIRN = RESULT
end
/* optional:
str = "1 NCHI" ChNum
writeln(output, str)
*/
end
if (prgvers >= 5) then
do
GETNEXTFGRN i
i = RESULT
end
else do
i = i + 1
end
end
writeln(output, "0 TRLR")
if usereq then
EndString('Conversion done.'||NL||'Number of persons output: '||TotalIRN||,
NL||'Number of families output: '||TotalFGRN||NL)
else do
if output = scrdev then
Tell("Number of persons output: "||TotalIRN)
EndString("Number of families output: "||TotalFGRN)
end
EXIT
/*
* Read external comment files and output to the GEDCOM file
*/
ParseCommentFile: PROCEDURE EXPOSE output
parse arg iname,coms
if ~open(infile, iname, "r") then
return 0
do while ~eof(infile)
cline = GetNextCLine(infile)
if cline ~= "" | ~eof(infile) then do
if coms then
str = "2 CONT "||cline
else do
str = "1 NOTE "||cline
coms = 1
end
writeln(output, str)
end
end
close(infile)
return 0
/* read a line from a file; skip empty lines */
GetNextCLine: PROCEDURE
parse arg infile
ignl = ""
if ~eof(infile) then
ignl = readln(infile)
/* ignl = strip(ignl, 'b', ' '); * should we remove extra spaces? No! */
return ignl
ParseDate: PROCEDURE EXPOSE prgvers
parse arg datestr
/* replace all ".", "-" or "/" in the date by " " */
if datestr = '' then return datestr
datestr = upper(translate(datestr,' ','-./'))
if prgvers < 5 then do
/* replace ABOUT by ABT, BEFORE by BEF and AFTER by AFT */
if left(datestr, 5) = "ABOUT" then
datestr = "ABT"||right(datestr,length(datestr)-5)
else if left(datestr, 6) = "BEFORE" then
datestr = "BEF"||right(datestr,length(datestr)-6)
else if left(datestr, 5) = "AFTER" then
datestr = "AFT"||right(datestr,length(datestr)-5)
return datestr
end
else do
datesArray = "JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC"
/* As of v5, dates can be numeric, including 00-00-0000
* in front of date: < (=BEF), > (=AFT), ~ (=ABT),
* behind date: ? (uncertain), BC (=B.C.) [in that order!]
* Note: pre-v5 versions of Scion ignore the additional 1
* behind the GETxxxDATE commands
*/
retstr=""; leadstr=""; quay=""
if left(datestr, 1) = '~' then do
leadstr = 'ABT '
datestr = right(datestr, length(datestr)-1)
end
else if left(datestr, 1) = '<' then do
leadstr = 'BEF '
datestr = right(datestr, length(datestr)-1)
end
else if left(datestr, 1) = '>' then do
leadstr = 'AFT '
datestr = right(datestr, length(datestr)-1)
end
if right(datestr, 2) = 'BC' then do
retstr = ' B.C.'
datestr = strip(left(datestr, length(datestr)-2), 'T')
end
if right(datestr, 1) = '?' then do
quay = '?'
/* required furtheron! */
datestr = left(datestr, length(datestr)-1)
end
w1 = words(datestr)
if w1 > 0 then do
d1str = word(datestr, w1)
/* note that '0' IS a valid year! */
year = strip(d1str, 'L', '0')
if year = '' then
year = '0'
retstr = year||retstr
datestr = strip(left(datestr, length(datestr)-length(d1str)), 'T')
end
w1 = w1 - 1
if w1 > 0 then do
d1str = word(datestr, words(datestr))
if d1str ~= "00" then do
/* month specified */
monthname = word(datesArray, d1str)
retstr = monthname||' '||retstr
end
datestr = strip(left(datestr, length(datestr)-length(d1str)), 'T')
end
w1 = w1 - 1
if w1 > 0 then do
d1str = word(datestr, words(datestr))
if d1str ~= "00" then do
/* day specified */
retstr = strip(d1str,'L','0')||' '||retstr
end
datestr = left(datestr, length(datestr)-length(d1str))
end
return leadstr||retstr||quay
end
DoOutputDate: PROCEDURE
parse arg datestr, output
if datestr ~= "" then do
qy = right(datestr,1)
if qy="?" then
datestr = left(datestr, length(datestr)-1)
str = "2 DATE" datestr
writeln(output, str)
if qy="?" then
writeln(output, "3 QUAY 0")
end
return 0
DoOutputPlace: PROCEDURE
parse arg placestr, output
if placestr ~= "" then do
qy = right(placestr,1)
if qy="?" then
placestr = left(placestr, length(placestr)-1)
str = "2 PLAC" placestr
writeln(output, str)
if qy="?" then
writeln(output, "3 QUAY 0")
end
return 0
Tell: PROCEDURE EXPOSE outp scrdev
parse arg str
if outp then writeln(scrdev, str)
return 0
TellNN: PROCEDURE EXPOSE outp scrdev
parse arg str
if outp then writech(scrdev, str)
return 0
EndString: PROCEDURE EXPOSE outp output usereq scrdev pgopen pscr
parse arg str
if pgopen then Postmsg()
/* If you turned off stdout, no error messages will be shown! */
if usereq then
rtezrequest(str,'E_xit','Converter Message:','rt_pubscrname = '||pscr)
else
Tell(str || '0A'x)
if outp & ~usereq & (scrdev ~= stdout) then do
Tell("Press <return> to exit.")
readln(scrdev)
close(scrdev)
end
close(output)
EXIT
/* Let's make sure you get a nice message when you turn off the printer :-) */
IOERR:
bline = SIGL
say "I/O error #"||RC||" detected in line "||bline||":"
say sourceline(bline)
if pgopen then Postmsg()
EXIT